<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
  <meta charset="UTF-8">
  <title>新增收货地址</title>
  <link rel="stylesheet" href="/layui/css/layui.css" />
  <script type="text/javascript" src="/js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="/layer/layer.js"></script>
  <script type="text/javascript" src="/layui/layui.js" ></script>
</head>

<body>

<form class="layui-form" action="/addAddress/2" style="width: 650px;margin-top: 20px;">
  <div class="layui-form-item">
    <label class="layui-form-label">收件人</label>
    <div class="layui-input-block">
      <input id="userName" type="text" name="realname" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">电话</label>
    <div class="layui-input-block">
      <input type="phone" name="mobile" required lay-verify="required" placeholder="请输入电话" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item" >
    <label class="layui-form-label">地区</label>
    <div class="layui-input-block">
      <select name="zone" lay-verify="required">
        <option value="湖北">湖北</option>
        <option value="北京">北京</option>
        <option value="上海">上海</option>
        <option value="广州">广州</option>
        <option value="深圳">深圳</option>
        <option value="杭州">杭州</option>
      </select>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">详细地址</label>
    <div class="layui-input-block">
      <textarea name="street" required placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal"  lay-submit lay-filter="formDemo" type="submit">添加</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<script>
  //Demo
  layui.use('form', function() {
    var form = layui.form;
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    //监听提交
    form.on('submit(formDemo)', function(data) {
      var val = $("#userName").val();
      parent.layer.msg('收件人 ' +val + ' 添加成功！');
      parent.layer.close(index);
      parent.location.reload();
    });
  });
</script>

</body>

</html>